#breadcrumbBar {
  position: sticky;
  top: 0;
  z-index: 999;
}

.jenkins-breadcrumbs {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.7rem 0.5rem 0.75rem;
  backdrop-filter: blur(15px);

  &::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--table-background);
    opacity: 0.95;
  }

  & > ul {
    display: flex;
    align-items: center;
    list-style-type: none;
    margin: 0;
    padding: 0;
    flex: 1;
    flex-wrap: wrap;

    & > li {
      & > a {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0.2rem 0.4rem;
        font-weight: 500;
        font-size: 0.85rem;
        border-radius: 6px;
        color: var(--text-color);
        z-index: 0;
        text-decoration: none;

        &::before,
        &::after {
          content: "";
          position: absolute;
          top: -1px;
          left: -2px;
          bottom: -1px;
          right: -2px;
          border-radius: 6px;
          z-index: -1;
          opacity: 0;
          transition: var(--standard-transition)
        }

        &::before {
          background: var(--text-color);
        }

        &::after {
          box-shadow: 0 0 0 10px transparent;
        }

        &:hover {
          &::before {
            opacity: 0.05 !important;
            background: var(--text-color);
          }
        }

        &:focus, &:active {
          &::before {
            opacity: 0.1 !important;
            background: var(--text-color);
          }

          &::after {
            opacity: 0.05 !important;
            box-shadow: 0 0 0 5px var(--text-color);
          }
        }
      }
    }

    // '>' separator between two items
    .children,
    .separator {
      position: relative;
      width: 14px;
      height: 14px;
      margin: 6px;

      &::after {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        opacity: 0.5;
        transition: var(--standard-transition);
        background: var(--text-color);
        mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'%3E%3Ctitle%3EChevron Forward%3C/title%3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M184 112l144 144-144 144'/%3E%3C/svg%3E");
      }
    }

    .children {
      cursor: pointer;

      &:hover {
        &::after {
          opacity: 1;
          transform: rotate(90deg);
        }
      }

      &:active {
        &::after {
          transform: translateY(2px) rotate(90deg);
          opacity: 0.5;
        }
      }

      // Increase the hit target
      &::before {
        content: "";
        position: absolute;
        top: -14px;
        left: -5px;
        bottom: -14px;
        right: -5px;
        background: transparent;
      }
    }

    .separator {
      &:last-of-type {
        display: none;
      }
    }
  }
}

.jenkins-menu-dropdown-chevron {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 14px;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 0;
  margin-left: -14px;
  pointer-events: none;
  vertical-align: middle;
  transition: var(--standard-transition);
  background: transparent;

  &:hover {
    &::after {
      opacity: 1 !important;
    }
  }

  &:active {
    &::after {
      transform: translateY(2px);
      opacity: 0.5 !important;
    }
  }

  // Increase the hit target
  &::before {
    content: "";
    position: absolute;
    top: -7px;
    bottom: -7px;
    right: -20px;
    width: 20px;
    pointer-events: all;
  }

  &::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 14px;
    opacity: 0;
    transition: var(--standard-transition);
    background: var(--text-color);
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'%3E%3Ctitle%3EChevron Down%3C/title%3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M112 184l144 144 144-144'/%3E%3C/svg%3E");
    mask-position: center;
    mask-repeat: no-repeat;
  }
}

.model-link {
  position: relative;
  transition: var(--standard-transition) !important;

  &::before {
    content: "";
    position: absolute;
    top: -7px;
    left: -10px;
    bottom: -7px;
    right: -10px;
  }

  &:hover {
    .jenkins-menu-dropdown-chevron {
      margin-left: 1ch;
      pointer-events: all;

      &::after {
        opacity: 0.5;
      }
    }

    // For links with badges next to them, eg build monitor page, we need to shrink the margins of
    // the badge so that it doesn't cause a table column resize, yet doesn't change in appearance
    @media (hover: hover) {
      & + a.model-link:not(.model-link--float) {
        transform: translateX(10px);
        margin-right: calc((14px + 1ch) * -1) !important;
      }
    }
  }

  @media (hover: none) {
    & + a.model-link {
      transform: translateX(10px);
      margin-right: calc((14px + 1ch) * -1) !important;
    }

    .jenkins-menu-dropdown-chevron {
      margin-left: 1ch;

      &::after {
        opacity: 0.5;
      }
    }
  }
}

@media (hover: hover) {
  .inside {
    &:hover {
      margin-right: calc((14px + 1ch) * -1) !important;
    }
  }
}

.model-link--float {
  z-index: 0;

  &::before,
  &::after {
    content: "";
    position: absolute;
    top: -7px;
    left: -10px;
    bottom: -7px;
    right: -10px;
    opacity: 0;
    border-radius: 6px;
    transition: var(--standard-transition);
  }

  &::before {
    z-index: -2;
    background: var(--background);
  }

  &::after {
    z-index: -1;
    background: var(--text-color);
  }

  @media (hover: hover) {
    .jenkins-menu-dropdown-chevron {
      position: absolute;
      top: 1px;
      right: 0;
      margin-left: 0 !important;
    }
  }

  &:hover {
    z-index: 10;

    @media (hover: hover) {
      &::before,
      &::after {
        right: calc((2ch + 14px) * -1);
      }
    }

    &::before {
      opacity: 1;
    }

    &::after {
      opacity: 0.15;
    }

    .jenkins-menu-dropdown-chevron {
      @media (hover: hover) {
        right: calc((1ch + 14px) * -1);
      }

      &::after {
        opacity: 0.5;
      }
    }
  }
}

// TODO: Remove when YUI dropdowns are removed

#breadcrumb-menu .header {
  font-weight: bold;
  font-size: 0.875rem;
  pointer-events: none;
}

#breadcrumb-menu .separator {
  position: relative;
  display: block !important;
  color: transparent;
  overflow: hidden;
  width: 100%;

  &::after {
    content: "";
    position: absolute;
    top: 9px;
    left: -50vw;
    right: -50vw;
    background: var(--text-color);
    height: 2px;
    opacity: 0.1;
  }
}
